package simple.alert.rule.condition;

public class BreakConditionDecorator extends ConditionDecorator {

	private boolean alarming;

	public BreakConditionDecorator(ICondition decoratedOperator) {
		super(decoratedOperator);
	}

	@Override
	public boolean isMatch(long value) {
		if(!alarming) {
			if(decoratedOperator.isMatch(value)) {
				alarming = true;
				return true;
			}
			else {
				return false;
			}
		}
		else {
			if(!decoratedOperator.isMatch(value)) {
				alarming = false;
			}
			return false;
		}
	}

	@Override
	public String getDesc() {
		return "初次触达"+decoratedOperator.getDesc();
	}
	
}
